"""
dim1维度新高新低计算
支持最小周期设置
支持多少天内
"""
from research.calcor import calcor_base
class isnhnl(calcor_base):
    def __init__(self,timeperiod=10,mintimeperiod=None,indays=1,flags=[2,-2]):
        super().__init__(timeperiod=timeperiod,mintimeperiod=mintimeperiod,datatype="dim1")
        self.indays=indays
        self.flags=flags
    def calc(self):
        data=self.hisdata
        max0 = max(data)
        min0 = min(data)
        rst = 0
        if max0 in data[-self.indays:]:
            rst = self.flags[0]
        elif min0 in data[-self.indays:]:
            rst = self.flags[-1]
        return rst
